package com.aidex.biz.controller;

import java.util.List;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import com.aidex.common.core.page.PageDomain;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.poi.ExcelUtil;
import javax.validation.constraints.*;
import org.springframework.web.bind.annotation.*;
import com.aidex.common.core.controller.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import com.aidex.biz.domain.LinshiDeptManage;
import com.aidex.biz.service.LinshiDeptManageService;
import com.aidex.common.utils.SecurityUtils;

/**
 * 部门临时督办Controller
 * @author sean
 * @email 2074844820@qq.com
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/biz/bizLinshiDeptManage")
public class LinshiDeptManageController extends BaseController
{
    @Autowired
    private LinshiDeptManageService linshiDeptManageService;

    /**
     * 查询部门临时督办列表
     */
    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:list')")
    @GetMapping("/linshilist")
    public R<PageInfo> linshilist(LinshiDeptManage linshiDeptManage, HttpServletRequest request, HttpServletResponse response)
    {
//        linshiDeptManage.setDeptId(SecurityUtils.getDeptId());
        linshiDeptManage.setPage(new PageDomain(request, response));
        return R.data(linshiDeptManageService.findPage(linshiDeptManage));
    }

    /**
     * 查询部门临时督办列表
     */
    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:list')")
    @GetMapping("/list")
    public R<PageInfo> list(LinshiDeptManage linshiDeptManage, HttpServletRequest request, HttpServletResponse response)
    {
        linshiDeptManage.setDeptId(SecurityUtils.getDeptId());
        linshiDeptManage.setPage(new PageDomain(request, response));
        return R.data(linshiDeptManageService.findPage(linshiDeptManage));
    }


    /**
     * 获取部门临时督办详细信息
     */
    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:query')")
    @GetMapping(value = "/{id}")
    public R<LinshiDeptManage> detail(@PathVariable("id") String id)
    {

        return R.data(linshiDeptManageService.get(id));
    }

    /**
     * 新增部门临时督办
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:add')")
    @Log(title = "部门临时督办", businessType = BusinessType.INSERT)
    @PostMapping
    public R add(@RequestBody @Validated  LinshiDeptManage linshiDeptManage)
    {
        return R.status(linshiDeptManageService.save(linshiDeptManage));
    }

    /**
     * 修改部门临时督办
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:edit')")
    @Log(title = "部门临时督办", businessType = BusinessType.UPDATE)
    @PutMapping
    public R edit(@RequestBody @Validated LinshiDeptManage linshiDeptManage)
    {
        return R.status(linshiDeptManageService.save(linshiDeptManage));
    }


    /**
     * 删除部门临时督办
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:remove')")
    @Log(title = "部门临时督办", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public R remove(@PathVariable String[] ids)
    {
        return R.status(linshiDeptManageService.deleteLinshiDeptManageByIds(ids));
    }

    /**
     * 获取最大编号
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:query')")
    @GetMapping("/findMaxSort")
    public R findMaxSort()
    {
        return R.data(linshiDeptManageService.findMaxSort(new LinshiDeptManage()));
    }

    /**
     * 导出部门临时督办列表
     */
//    @PreAuthorize("@ss.hasPermi('biz:bizLinshiDeptManage:export')")
    @Log(title = "部门临时督办", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public R export(LinshiDeptManage linshiDeptManage)
    {
        List<LinshiDeptManage> list = linshiDeptManageService.findList(linshiDeptManage);
        ExcelUtil<LinshiDeptManage> util = new ExcelUtil<LinshiDeptManage>(LinshiDeptManage.class);
        return util.exportExcel(list, "部门临时督办数据");
    }

}
